package my.sample.icmp;

import java.net.InetAddress;

public class TimeoutTest {

	/**
	 * @param args
	 */
	// private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(TimeoutTest.class);
	public static void main(String[] args) {
		
		System.out.println("IP : " + args[0] + " timeout : " + args[1] + " total : " + args.length + " args");
		if (!(args.length < 2)) {
			try {
				InetAddress adr = InetAddress.getByName(args[0]);
				long start = System.currentTimeMillis();
				if (adr.isReachable(Integer.parseInt(args[1]))) {
					System.out.println(args[0] + " is reachable");
				} else {
					System.out.println(args[0] + " not reachable");
				}
				System.out.println("Time taken : " + (System.currentTimeMillis() - start) + " ms");
			} catch (Exception e) {
				System.out.println("Exception : " + e);
			}
		} else {
			System.out.println("provide ip as input");
		}

	}
}
